ubuntu下AI服务器环境的部署准备 您所在的位置:网站首页 云服务器 部署ai ubuntu下AI服务器环境的部署准备

ubuntu下AI服务器环境的部署准备

2024-07-01 22:06| 来源: 网络整理| 查看: 265

本篇介绍下AI服务器的环境部署准备。基于深度学习技术的AI浪潮已经风靡了一段时间,但是每一次部署环境、准备一些测试都是东搜搜西看看,这次决定自己整理下常用的AI服务器环境部署工具及安装方法。 1、系统,AI训练推荐使用Ubuntu,我用的是Ubuntu1604,现在2004都已经出来了。系统的获取地址 http://old-releases.ubuntu.com/releases/ 2、apt源,配置这些环境最好还是在有网络的环境下,如果没有网络可以考虑使用docker会少装一些东西。选一个好一些的apt源绝对可以让你事半功倍。 3、GPU-驱动,既然是AI服务器目前看来是离不开NVIDIA GPU,驱动是必不可少啦 4、CUDA,基于GPU的并行编程开源SDK 5、CUDNN,基于CUDA的深度学习算法SDK 6、NCCL,基于CUDA和CUDNN的并行算法库 7、OPENMPI,通用并行计算库 8、PYTHON,机器学习 深度学习常用开发语言 9、TensorFLow,谷歌开源的机器学习库

一、系统安装

就不详述,一般在服务器上装系统,采用BMC远程连接,用本地镜像即可操作,很方便。

二、apt源配置

1.备份原始文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup 2.修改文件并添加国内源 vi /etc/apt/sources.list 3.注释源文件内的源并添加如下地址(ubuntu1604)

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse ##测试版源 deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse #源码 deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse ##测试版源 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse #Canonical 合作伙伴和附加 deb http://archive.canonical.com/ubuntu/ xenial partner deb http://extras.ubuntu.com/ubuntu/ xenial main

可以自行搜索apt阿里源,电信源,163源

4.更新源 sudo apt-get update 5.常见的修复安装命令 sudo apt-get -f install

三、GPU驱动

1、根据GPU型号选择驱动,高版本的驱动是向下兼容低版本,建议选择新的驱动。一般我习惯使用run文件进行安装。 比如 NVIDIA-Linux-x86_64-418.87.01.run bash NVIDIA-Linux-x86_64-418.87.01.run 2、安装过程一般不会很顺利,有的Ubuntu装的是轻量版可能没有gcc g++,有的可能存在冲突,这个具体问题得看报错,很多这方面的bug解决案例。缺少安装包的直接apt install即可,其它错误可以搜搜看~

四、CUDA

1、cuda sudo bash cuda_10.1.243_418.87.00_linux.run --silent --toolkit --samples 一键安装貌似也没有出过很多错误

五、CUDNN & NCCL

我习惯用tar包解压拷贝修改连接的方式来做比如cudnn #cudnn sudo tar -xvf cudnn-10.0-linux-x64-v7.5.0.56.tgz sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64;cd /usr/local/cuda/lib64; sudo rm libcudnn.so libcudnn.so.7;sudo ln -s libcudnn.so.7.5.0 libcudnn.so.7;sudo ln -s libcudnn.so.7 libcudnn.so sudo rm -Rf cuda 后来吧,发现大家用dpkg直接安装deb包也挺方便的,如下链接有很多版本可以选择。 https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1604/x86_64/

六、PYTHON

sudo apt-get -y install python-dev python-pip sudo apt-get -y install python3-dev python3-pip 不过我还是推荐使用anaconda或者minianacoda,这个套装里面有很多科学计算库,省得自己一个个pip install。

七、OPENMPI

https://www.open-mpi.org/faq/?category=building#easy-build ./configure make all insatll 把之前装的lib库都加下环境变量 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/openmpi/lib

八、TensorFlow

这个安装方式很多 最简单的, pip install tensorflow-gpu1.14(GPU) pip install tensorflow1.14(CPU)

源码安装,毕竟有人喜欢这个:

pip3 install -U --user future #2. Download Bazel in advance(175M) https://github.com/bazelbuild/bazel/releases #3. run the installer #set the bazel version in advance!!! chmod +x bazel-0.25.3-installer-linux-x86_64.sh ./bazel-0.25.3-installer-linux-x86_64.sh --user #4. set up the environment echo "export PATH="$PATH:$HOME/bin"" >> /etc/profile source /etc/profile #unzip tensorflow-r2.0.zip unzip -q tensorflow-r2.0.zip mv tensorflow-r2.0 tensorflow cd tensorflow export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 source /etc/profile && echo -e "/usr/bin/python3\n/usr/lib/python3/dist-packages\n n\n n\n n\n Y\n n\n7.0,7.0\n \n\n n\n \n n\n"| ./configure echo "/usr/local/lib">>/etc/ld.so.conf echo "/usr/local/cuda/lib64">>/etc/ld.so.conf ldconfig ~/bin/bazel build --config=opt --config=cuda --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" //tensorflow/tools/pip_package:build_pip_package #build the package ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg #set tensorflow version!!! pip install /tmp/tensorflow_pkg/*.whl ######version!!!###### echo "......Tensorflow-now-is-installed..."


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有